/**
 * Project Name:YCApiServer-admin
 * File Name:LyricsTemplateService.java
 * Package Name:com.yc.music.admin.service
 * Date:2016年6月2日下午1:39:02
 * Copyright (c) 2016 
 *
 */
package com.yc.music.service.service21;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.yc.music.common.context.YcContext;
import com.yc.music.common.util.RoomUtil;
import com.yc.music.mapper.dao.LyricsTemplateMapper;
import com.yc.music.model.activity.MusicActivityWorkVo;
import com.yc.music.model.lyricstemplate.LyricsTemplate;


/**
 * ClassName: LyricsTemplateService <br/>
 * Function: 作词模板. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2016年8月11日 下午1:39:02 <br/>
 *
 * @author qinhaiguan
 * @version 
 */
@Service
public class LyricsTemplateService {

	@Value("${Pic_QiLiu}")
	private String pIC_QiLiu;
	
	@Value("${Audio_QiLiu}")
	private String audio_QiLiu;
	@Autowired
	private LyricsTemplateMapper lyricsTemplateMapper;
	
	public Map<String,Object> lyricsTemplatePage(Integer page,Map<String,Object> result) throws Exception{
    	int rows=10;
		page=page==0?page=1:page;
		int start=(page-1)*rows;
		List<LyricsTemplate> list = lyricsTemplateMapper.getLyricsTemplatePage(start, rows);
		for (LyricsTemplate vo : list) {
			vo.setMp3(RoomUtil.jointDomain(vo.getMp3(),audio_QiLiu));
		}
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YcContext.EMPTY_STRING);
		result.put(YcContext.DATA, list);
        return result;
    }
	
	
	public void saveLyricsTemplate(LyricsTemplate lyricsTemplate) throws Exception{
		
		lyricsTemplateMapper.saveLyricsTemplate(lyricsTemplate);
	}
	
	public LyricsTemplate getLyricsTemplateById(int id) {
		LyricsTemplate lyricsTemplate = lyricsTemplateMapper.getLyricsTemplateById(id);
		
		return lyricsTemplate;
	}
	
	
	public void updateLyricsTemplate(LyricsTemplate lyricsTemplate) throws Exception{
		
		lyricsTemplateMapper.updateLyricsTemplate(lyricsTemplate);
	}
	
	public void deleteLyricsTemplate(int id) throws Exception{
		lyricsTemplateMapper.deleteLyricsTemplate(id);
	}
	
}
